<#assign base=request.contextPath />
<#assign oneLabel="ERP管理">

<#assign twoLabel="合同管理">
<#assign twoUrl=base+"/suppiler/list">

<#assign leafLabel="合同明细">
<!DOCTYPE html>
<html lang="en">
<head>
	<#include "/commons/headImport.ftl">
</head>
<body>
<#include "/commons/header.ftl">					
<form class="form-horizontal" name="formName" method="post">
<#include "/commons/hiddenField.ftl">
<div class="row">
	<div class="col-xs-12">
		<#include "_contract_base.ftl">

		<div class="col-sm-12">
			<div class="widget-box transparent">
				<div class="widget-header widget-header-flat">
					<h5 class="widget-title lighter">
						<i class="ace-icon fa fa-signal"></i>收款信息
					</h5>
				</div>

				<div class="widget-body">
					<div class="widget-main no-padding">
						<table class="table table-bordered table-striped">
							<thead class="thin-border-bottom">
								<tr>
									<th class="center" width="5%">#</th>
									<th width="10%">期</th>
									<th width="15%">应收金额</th>
									<th width="15%">已收金额</th>
									<th width="10%">未收金额</th>
									<th width="15%">占比(%)</th>
									<th width="30%">备注</th>
								</tr>
							</thead>
							<tbody>
								<#if contractDO.receivableList??>
								<#list contractDO.receivableList as rece>
								<tr>
									<td>${rece_index+1}</td>
									<td><a href="javascript:openPayLog('${rece.id}');">第  ${rece.periods} 期</td>
									<td>${(rece.pageTotalAmount?string.currency)!0.0}</td>
									<td>
										${(rece.pageReceivedAmount?string.currency)!0.0}
									</td>
									<td>${((rece.pageTotalAmount-rece.pageReceivedAmount)?string.currency)!0.0}</td>
									<td>
										${((rece.pageTotalAmount/contractDO.pageTotalAmount)?string('0.00%'))!0}
									</td>
									<td>${rece.remark}</td>
								</tr>
								</#list>
								</#if>
								<#if !contractDO.receivableList?? ||((contractDO.receivableList)?size==0)>
									<tr>
										<td colspan="8" class="center">没有查询任何数据</td>
									</tr>
								</#if>
							</tbody>
						</table>						
					</div><!-- /.widget-main -->
				</div><!-- /.widget-body -->
			</div><!-- /.widget-box -->
		</div><!-- /.col -->
		
		<div class="col-sm-12">
			<div class="widget-box transparent">
				<div class="widget-header widget-header-flat">
					<h5 class="widget-title lighter">
						<i class="ace-icon fa fa-signal"></i>开支信息
					</h5>
				</div>

				<div class="widget-body">
					<div class="widget-main no-padding">
						<table class="table table-bordered table-striped">
							<thead class="thin-border-bottom">
								<tr>
									<th class="center" width="5%">#</th>
									<th width="10%">支出类型</th>
									<th width="15%">项目名称</th>
									<th width="15%">金额</th>
									<th width="55%"></th>
								</tr>
							</thead>
							<tbody>
								<#assign artificialAmount=0>
								<#assign meriaAmount=0>
								<#assign otherAmount=0>
								<#if contractDO.paymentList??>
								<#list contractDO.paymentList as pay>
								<tr>
									<td class="center">${pay_index+1}</td>
									<td>
										<#if pay.type==0> 
												<span class="label label-sm label-warning arrowed arrowed-righ">人工支出</span>
												<#assign artificialAmount=artificialAmount+pay.pageAmount>
											<#elseif pay.type==10>
												<span class="label label-sm label-inverse arrowed-in">材料支出</span>
												<#assign meriaAmount=meriaAmount+pay.pageAmount>
											<#else>
												<span class="label label-sm label-success">其他支出</span>
												<#assign otherAmount=otherAmount+pay.pageAmount>
										</#if>
									</td>
									<td>${pay.name!'--'}</td>
									<td>${(pay.pageAmount?string.currency)!0.0}</td>
									<td>
										<a class="btn btn-minier btn-info detail_id" a="${pay.name}" 
											contract=${contractDO.id} type=${pay.type} url="${base}/payment/queryDetail" 
											href="javascript:void(0);">
											<i class="icon-search bigger-120"></i>详细
										</a>
									</td>
								</tr>
								</#list>
								</#if>
								<#if !contractDO.paymentList?? ||((contractDO.paymentList)?size==0)>
									<tr>
										<td colspan="18" class="center">没有查询任何数据</td>
									</tr>
								</#if>
							</tbody>
						</table>
					</div><!-- /.widget-main -->
				</div><!-- /.widget-body -->
			</div><!-- /.widget-box -->
		</div><!-- /.col -->		

		<div class="col-sm-12">
			<div class="widget-box transparent">
				<div class="widget-header widget-header-flat">
					<h5 class="widget-title lighter">
						<i class="ace-icon fa fa-signal"></i>统计信息
					</h5>
				</div>

				<div class="widget-body">
					<div class="widget-main padding-4">
						<table class="table table-striped table-bordered">
							<tr>
								<th width="10%">合同金额</th>
								<th width="10%">已收金额</th>
								<th width="10%">未收金额</th>
								<th width="45%">支出金额</th>
								<th width="15%">盈利</th>
								<th width="10%">毛利比</th>
							</tr>
							<tr>
								<td>${contractDO.pageTotalAmount?string.currency}</td>
								<td>${((contractDO.confirmAmount/100)?string.currency)!0.0}</td>
								<td>${((contractDO.pageTotalAmount-contractDO.confirmAmount/100)?string.currency)!0.0}</td>
								<td>
									材料费:${(meriaAmount?string.currency)!0.0}，
									人工费: ${(artificialAmount?string.currency)!0.0}，
									其他费:${(otherAmount?string.currency)!0.0}，
									小计:${((meriaAmount+artificialAmount+otherAmount)?string.currency)!0.0}
								</td>
								<td>
									<#assign aAmount=(contractDO.confirmAmount/100.0-(meriaAmount+artificialAmount+otherAmount))!0>
									<#if (aAmount>0) >
										<span class="label label-sm label-success">
											盈利
										</span>
										<#else>
										<span class="label label-sm label-warning arrowed arrowed-righ">
											亏损
										</span>
									</#if>
									${(aAmount?string.currency)!0.0}
								</td>
								<td>${((contractDO.confirmAmount/100.0-(meriaAmount+artificialAmount+otherAmount))/contractDO.pageTotalAmount)?string("0.00%")}</td>
							</tr>
						</table>
					</div><!-- /.widget-main -->
				</div><!-- /.widget-body -->
			</div><!-- /.widget-box -->
		</div><!-- /.col -->
	</div><!-- /.col -->
</div><!-- /.row -->
</form>
<div class="hr hr32 hr-dotted"></div>
<div class="clearfix">
	<div class="col-md-offset-2 col-md-9">
		<button class="btn btn-xs return_class" type="button" url="${base}/contract/list">
			<i class="icon-reply bigger-110"></i>返回
		</button>
	</div>
</div>
<#include "/commons/footer.ftl">
</body>
<script src="${base}/static/layer/layer.js"></script>
<script type="text/javascript">
	jQuery(function($) {
	   $(".detail_id").click(function(){
	   		var url=$(this).attr("url");
	   		url=url+"?qname="+$(this).attr("a")+"&qcontractId="+$(this).attr("contract")+"&qtype="+$(this).attr("type");
			layer.open({
		      type: 2,
		      title: '支出明细',
		      maxmin: true,
		      shadeClose: true, //点击遮罩关闭层
		      area : ['800px' , '450px'],
		      content: url
		    });
	   	});
	});
	
	function openPayLog(receivablesId) {
		var url='${base}/receivablesDetail/getByReceivablesId/'+receivablesId;
		layer.open({
	      type: 2,
	      title: '查看收款记录',
	      maxmin: true,
	      shadeClose: true, //点击遮罩关闭层
	      area : ['800px' , '450px'],
	      content: url
	    });
	}
</script>
</html>
